import request from '../utils/request';
import { mapToParam } from '../utils';

// export function DownloadTemplete() {
//   return request('api/downloadCase/', {
//     method: 'GET',
//     headers: {
//       Accept: 'application/json',
//       'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
//     },
//     // body: mapToParam(param),
//   });
// }

export function updateCase(updateparam) {
  return request('api/updateCase/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(updateparam),
  });
}

export function deleteCase(recordParams) {
  return request('api/deleteCase/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(recordParams),
  });
}

export function getCase({ rt_version, project_name, assigne, dev_status, test_status, module }) {
  return request(`api/searchCase/?rt_version=${rt_version}&project_name=${project_name}&assigne=${assigne}&dev_status=${dev_status}&test_status=${test_status}&module=${module}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
  });
}

export function sendSmokeReport(reportparam) {
  return request('api/sendSmokeReport/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(reportparam),
  });
}

export function getSmokeResult({ fix_version, project_name }) {
  return request(`api/getSmokeResult/?fix_version=${fix_version}&project_name=${project_name}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
  });
}

// 需要用到的project信息
export function GetProjectList() {
  return request('api/GetProjectList/', {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
  });
}
